package com.itheima.cases.list_cases;

import java.util.LinkedList;

public class Test3 {
    public static void main(String[] args) {
        // LinkedList
        LinkedList<String> queue = new LinkedList<>();
        // 尾部添加
        queue.addLast("timor");
        queue.addLast("bag");
        queue.addLast("lisa");
        queue.addLast("realiy");
        System.out.println(queue);
        // 出队
        System.out.println(queue.removeFirst());
        System.out.println(queue.removeFirst());
        System.out.println(queue.removeFirst());
        System.out.println(queue);
        System.out.println("--------------------------------------------------");

        // 2、模拟栈
        LinkedList<String> stack = new LinkedList<>();
        // 压栈
        stack.addFirst("第1颗子弹");
        stack.addFirst("第2颗子弹");
        stack.addFirst("第3颗子弹");
        stack.addFirst("第4颗子弹");
        stack.addFirst("第5颗子弹");
        stack.addFirst("第6颗子弹");
        System.out.println(stack);
        // 出栈(pop)
        System.out.println(stack.removeFirst());
        System.out.println(stack.removeFirst());
        System.out.println(stack.removeFirst());
        System.out.println(stack.removeFirst());
        System.out.println(stack.removeFirst());
        System.out.println(stack);
    }
}
